import Vue from 'vue'
import Router from 'vue-router'
import Login from "@/components/login/Login";
import Home from "@/components/Home";
import Regdit from "@/components/login/Regdit";
import RestPassword from "@/components/login/RestPassword";
import ClassList from "@/components/classlist/ClassList";
import MyClass from "@/components/myclass/MyClass";
import MyTest from "@/components/mytest/MyTest";
import User from "@/components/user/User";
import Test from "@/components/test/Test";
import Class from "@/components/class/Class";
import ClassVideo from "@/components/myclass/ClassVideo";
import EditTestPaper from "@/components/testPaper/EditTestPaper";
import Exam from "@/components/mytest/Exam";
import Analysis from "@/components/analysis/Analysis";


Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const router=new  Router({
  mode:'history',
  routes: [
    {path: '/',redirect:'/login'},
    {path:'/login',name:'Login',component:Login},
    {path:'/regdit',name:'Regdit',component:Regdit},
    {path: '/resetPwd',name: 'RestPassword',component:RestPassword  },
    {path:'/home',name: 'Home',component: Home,
      redirect: '/classList',
      meta: {need2Login: true},
      children:[
        {path:'/classList',name:'ClassList',component:ClassList,meta: {need2Login: true},},
        {path:'/myClass',name: 'MyClass',component: MyClass,meta: {need2Login: true}},
        {path:'/myTest',name: 'MyTest',component: MyTest,meta: {need2Login: true}},
        {path:'/user',name: 'User',component: User,meta: {need2Login: true,needAdmin:true}},
        {path: '/test',name: 'Test',component: Test,meta: {need2Login: true,needAdmin:true}},
        {path: '/class',name: 'Class',component: Class,meta: {need2Login: true,needAdmin:true}},
        {path: '/video',name: 'ClassVideo',component: ClassVideo,meta: {need2Login: true}},
        {path: '/analysis',name: 'Analysis',component: Analysis,meta: {need2Login: true,needAdmin:true}},
      ]
    },
    {path: '/editPaper',name: 'EditTestPaper',component: EditTestPaper,meta: {need2Login: true,needAdmin:true}},
    {path: '/exam',name: 'Exam',component: Exam ,meta: {need2Login: true}},
  ],
})


export default router;


